<template>
	<om-page :title="pageTitle">
		<om-formpage :hasSearch="false" :datas="commonData.datas" :userid="userId">
		</om-formpage>
		<uni-fab horizontal="right" @trigger="trigger" direction="vertical" :content="buttons" :scrollTop="scrollTop" />
		<tui-loadmore :visible="commonData.loadding"></tui-loadmore>
		<tui-nomore :visible="!commonData.pullUpOn"></tui-nomore>
	</om-page>
</template>

<script>
	import listLoad from '../../../static/js/listLoad.js';
	import {
		mapState
	} from 'pinia';
	import {
		useLoginUserStore
	} from '@/stores/login-user.js'
	const app = getApp();
	export default {
		data() {
			return {
				scrollTop: 0,
				buttons: [app.globalData.button.home],
				commonData: {
					datas: []
				},
				pageTitle: ""
			};
		},
		computed: mapState(useLoginUserStore,['userId']),
		methods: {
			trigger(e) {
				if (e.item.text === '返回首页') {
					uni.switchTab({
						url: '/pages/main/main/main'
					});
				} else if (e.item.text === '返回顶部') {
					this.scrollTop = 0;
					uni.pageScrollTo({
						scrollTop: 0
					});
				}
			},
			searchClick(e) {
				let _that = this;
				_that.initData(this, 'wxCommon/getPendingList', {
					zuserName: e
				});
			}
		},
		onLoad: function(options) {
			let _that = this;
			this.pageTitle = (options.title || '待处理')
			uni.setNavigationBarTitle({
				title: this.pageTitle
			});
		},
		onShow() {
			listLoad.initData(this, 'wxCommon/getPendingList').then(res => {
				uni.setStorageSync('pendingList', this.commonData.datas)
			});
		},
		onPageScroll(e) {
			let _that = this;
			_that.scrollTop = e.scrollTop;
			let buttons = _that.buttons;
			if (e.scrollTop > 5) {
				if (_that.buttons.length === 1) {
					buttons.unshift(app.globalData.button.top);
					_that.buttons = buttons;
				}
			} else {
				if (_that.buttons.length === 2) {
					buttons.shift();
					_that.buttons = buttons;
				}
			}
		},
		//页面相关事件处理函数--监听用户下拉动作
		onPullDownRefresh: function() {
			listLoad.pullDownRefresh(this);
		},

		// 页面上拉触底事件的处理函数
		onReachBottom: function() {
			this.commonData.pullUpOn = false
			return
		}
	};
</script>

<style></style>